<?php

use yii\helpers\Html;
use yii\grid\GridView;

$this->title = Yii::t('app', 'Customer Contacts');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-contact-index">

   <div class="box">
        <div class="box-header">
            <h4>客户联系人列表</h4>
        </div>
        <div class="box-body">
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            'layout'  =>  "{items}\n{summary}\n{pager}",
            'columns' => [
                ['class' => 'yii\grid\SerialColumn'],

              
                [
                    'headerOptions' => ['width' => '20%'],
                    'attribute' => 'product.code',
                    'value' => function ($model) {
                           return $model->product->code;
                    },
                ],

                [
                    'headerOptions' => ['width' => '20%'],
                    'attribute' => 'product.name',
                    'value' => function ($model) {
                           return $model->product->name;
                    },
                ],
                
                [
                    'headerOptions' => ['width' => '12%'],
                    'attribute' => 'p_name',
                    'value' => function ($model) {
                           return $model->p_name;
                    },
                ],
                
                [
                    'headerOptions' => ['width' => '12%'],
                    'attribute' => 'p_phone',
                    'value' => function ($model) {
                           return $model->p_phone;
                    },
                ],
               
                [
                    'headerOptions' => ['width' => '12%'],
                    'attribute' => 'p_mail',
                    'value' => function ($model) {
                           return $model->p_mail;
                    },
                ],
                
                [
                    'headerOptions' => ['width' => '12%'],
                    'attribute' => 'p_department',
                    'value' => function ($model) {
                           return $model->p_department;
                    },
                ],

                [
                  'attribute' => 'user_id',
                  'headerOptions' => ['width' => '12%'],
                  'value' => function($model){
                        return isset($model->user) ? $model->user->name : '管理员';
                  }
                ],
            ],
        ]); ?>
        </div>
    </div>
</div>
